| Visual Basic (Declaration) | |
|---|---|
Public Shared ReadOnly Property Factory As IFactory(Of T) | |
| C# | |
|---|---|
public static IFactory<T> Factory {get;} | |
Library/Library.Test/TestFactories.cs
| C# | Copy Code |
|---|---|
try { GC.KeepAlive(Singleton<BadObject>.Instance); Assert.Fail(); } catch(ApplicationException ae) { Assert.AreEqual("BadObject", ae.GetBaseException().Message); } try { Singleton<BadObject>.Factory.Create(); Assert.Fail(); } catch (ApplicationException ae) { Assert.AreEqual("BadObject", ae.GetBaseException().Message); } | |
| VB.NET | Copy Code |
|---|---|
Try GC.KeepAlive(Singleton(Of BadObject).Instance) Assert.Fail() Catch ae As ApplicationException Assert.AreEqual("BadObject", ae.GetBaseException().Message) End Try Try Singleton(Of BadObject).Factory.Create() Assert.Fail() Catch ae As ApplicationException Assert.AreEqual("BadObject", ae.GetBaseException().Message) End Try | |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
Singleton<T> ClassSingleton<T> Members
IFactory